<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="com.jimet.process.*"%>
<%@page import="java.text.*"%>
<%@page import="java.util.*"%>
<%@page import="com.jimet.objects.*"%>
<%@ include file="../includes/webUserAuthenticatedPageStart.jsp" %>
<%
SimpleDateFormat dFormat2F 		= new SimpleDateFormat("dd.MM.yyyy 00:00:00.0",new Locale("tr","TR"));	
SimpleDateFormat dFormat2ViewF 	= new SimpleDateFormat("dd.MM.yyyy",new Locale("tr","TR"));	

response.setContentType("text/html;charset=UTF-8"); 
request.setCharacterEncoding("UTF-8"); 
response.setLocale(new java.util.Locale("tr", "TR"));
response.setCharacterEncoding("UTF-8"); 

FilterParamsNew filterView = (FilterParamsNew)session.getAttribute("filterNew");
if(filterView==null)
{
	filterView = new FilterParamsNew();
	session.setAttribute("filterNew",filterView);
}

LinkedHashMap<String,Vector<String>> filtersHash 	= filterView.getFilterParams();
Iterator<String> filterEn 		= filtersHash.keySet().iterator();

int numTotalElementsInFilter	= filtersHash.size();

int numRowsInCol1				= (int)Math.ceil(((double)numTotalElementsInFilter)/2);
int numRowsInCol2				= numTotalElementsInFilter - numRowsInCol1;

%>


	<table border="0" cellpadding="0" cellspacing="0" class="table table-condensed" style="margin-bottom:0px;">
		<tr>
			<td style="margin-top:0px;background-color: whiteSmoke;">
				<table cellpadding="0" cellspacing="0" border="0"  class="table table-condensed" style="width: 860px;margin: 0px auto;margin-bottom:0px;"  id="filterContainerDiv">
					<tr>
						<td style="vertical-align: top;margin-top:0px;background-color: whiteSmoke;">
							<table cellpadding="0" cellspacing="0" border="0" class="table table-condensed" style="width: 415px;margin-bottom:0px;">
					<% 		for ( int i=0; i<numRowsInCol1 && filterEn.hasNext() ;i++ ){
					
					String filterKey 	= (String) filterEn.next();
					Vector<String> filtersVec 	= (Vector<String>)filtersHash.get( filterKey );
					String labelName	= (String) filtersVec.get(0);
					String type			= (String) filtersVec.get(1);
					String operator		= (String) filtersVec.get(2);
					String paramValue	= (String) filtersVec.get(3);
					String paramText	= (String) filtersVec.get(4);
					String elemHtml 	= "" ;
					String elemLabel	= "";
					
					if(type.equals("combo"))
					{
						elemHtml	= "<div class=\"m-input-prepend\">";
						elemHtml	+= "<span class=\"add-on\" style=\"background:transparent;\"><div style=\"width:165px;text-align:center;\">"+labelName+"</div></span>";
												
						elemHtml +=
							"<input type=\"hidden\" id=\""+filterKey+"_op\" name=\""+filterKey+"_op\" value=\""+operator+"\" >" +
							"<select style=\"width: 230px;border: 1px solid #eeeeee;\" onblur=\"if(this.selectedIndex>=0){document.getElementById('"+ 
									filterKey +"_text').value=this.options[this.selectedIndex].innerHTML};\" onfocus=\"loadSelect('"+
									filterKey+"','/common/process/fillSelectProcessNewXML.jsp',token+'&elementType="+
									filterKey+"&elementToSelect='+this.options[this.selectedIndex].value,0,1);this.onfocus='';\" "+
									"id=\""+filterKey+"\" name=\""+filterKey+"\" class=\"m-wrap\">" + 
								"<option value=\""+paramValue+"\">"+paramText+"</option>"+
							"</select>" +
							"<input type=\"hidden\" id=\""+filterKey+"_text\" name=\""+filterKey+"_text\" value=\""+paramText+"\" />";
						
						elemHtml	+= "</div>";	
					}
					else if( type.equals("text"))
					{
						elemHtml	= "<div class=\"m-input-prepend\">";
						elemHtml	+= "<span class=\"add-on\" style=\"background:transparent;\"><div style=\"width:165px;text-align:center;\">"+labelName+"</div></span>";
												
						if( operator.equals(""))
						{
							elemHtml +=
								"<input type=\"hidden\" id=\""+filterKey+"_op\" name=\""+filterKey+"_op\" value=\"LIKE\" >" +
								"<input type=\"text\" id=\""+filterKey+"\" name=\""+filterKey+"\" value=\""+ paramValue +"\" class=\"m-wrap\" style=\"margin-bottom:0px;\"/> "+
								"<input type=\"hidden\" id=\""+filterKey+"_text\" name=\""+filterKey+"_text\" value=\""+paramValue+"\" />" ;
						}
						else
						{
							elemHtml += 
								"<input type=\"hidden\" id=\""+filterKey+"_op\" name=\""+filterKey+"_op\" value=\"LIKE\" >" +
								"<input type=\"text\" id=\""+filterKey+"\" name=\""+filterKey+"\" value=\""+ paramValue +"\"  class=\"m-wrap\" style=\"margin-bottom:0px;\"/> "+
								"<input type=\"hidden\" id=\""+filterKey+"_text\" name=\""+filterKey+"_text\" value=\""+paramValue+"\" />" ;
						}
						
						elemHtml	+= "</div>";

					}
					else if( type.equals("number"))
					{
						elemHtml	= "<div class=\"m-input-prepend\">";
						elemHtml	+= "<span class=\"add-on\" style=\"background:transparent;\"><div style=\"width:165px;text-align:center;\">"+labelName+"</div></span>";
												
						elemHtml +=
							"<input type=\"text\" onkeypress=\"return numbersonly(event);\" id=\""+filterKey+"\" name=\""+filterKey+"\" value=\""+ paramValue +"\" class=\"m-wrap\" /> "+
							"<input type=\"hidden\" id=\""+filterKey+"_text\" name=\""+filterKey+"_text\" value=\""+(paramValue.equals("-1")||paramValue.equals("")?"": paramValue)+"\" style=\"margin-bottom:0px;\" />" +
							"<input type=\"hidden\" id=\""+filterKey+"_op\" name=\""+filterKey+"_op\" value=\""+operator+"\" >";	
						
						elemHtml	+= "</div>";						
	
					}			
					else if( type.equals("datetime"))
					{
						elemHtml	= "<div class=\"m-input-prepend\">";
						elemHtml	+= "<span class=\"add-on\" style=\"background:transparent;\"><div style=\"width:165px;text-align:center;\">"+labelName+"</div></span>";
												
						elemHtml +=
							"<input type=\"hidden\" id=\""+filterKey+"_op\" name=\""+filterKey+"_op\" value=\""+operator+"\" >" +	
							"<input type=\"text\" id=\""+filterKey+"\" name=\""+filterKey+"\" class=\"m-wrap\" readonly=\"readonly\" style=\"margin-bottom:0px;\" >";						
						elemHtml	+= "</div>";							
					}
					else if( type.equals("date"))
					{
						elemHtml	= "<div class=\"m-input-prepend\">";
						elemHtml	+= "<span class=\"add-on\" style=\"background:transparent;\"><div style=\"width:165px;text-align:center;\">"+labelName+"</div></span>";
												
						elemHtml +=
							"<input type=\"hidden\" id=\""+filterKey+"_op\" name=\""+filterKey+"_op\" value=\""+operator+"\" >" +	
							"<input type=\"text\" id=\""+filterKey+"\" name=\""+filterKey+"\" class=\"m-wrap\" readonly=\"readonly\" style=\"margin-bottom:0px;\" >";	

						elemHtml	+= "</div><script>"+	
						
						"$( \"#"+filterKey+"\" ).datepicker({"+
						"	changeMonth: true ,"+
						"	changeYear: true "+
					
						"});"+
						"</script>";
						
					}
		%>
					<tr>	
						<td style="text-align: left;margin-top:0px;padding:0px;background-color: whiteSmoke;">
							<%=elemHtml%>
						</td>				
					</tr>								
		<%			
				}
		%>									
				</table>
			</td>
			<td style="background-color: whiteSmoke;"><img src="<%=JimetConfiguration.getString("APPLICATION.URL")%>common/img/spacer.gif" style="width:10px;height: 100%;"></td>
			<td style="vertical-align: top;margin-top:0px;background-color: whiteSmoke;">
				<table cellpadding="0" cellspacing="0" border="0" style="width: 415px;margin-bottom:0px;" class="table table-condensed">
		<% 		for ( int i=0; i<numRowsInCol2 && filterEn.hasNext() ;i++ ){
					
					String filterKey 	= (String) filterEn.next();
					Vector<String> filtersVec 	= (Vector<String>)filtersHash.get( filterKey );
					String labelName	= (String) filtersVec.get(0);
					String type			= (String) filtersVec.get(1);
					String operator		= (String) filtersVec.get(2);
					String paramValue	= (String) filtersVec.get(3);
					String paramText	= (String) filtersVec.get(4);
					String elemHtml 	= "" ;
					String elemLabel	= "";
					
					if(type.equals("combo"))
					{
						elemHtml	= "<div class=\"m-input-prepend\">";
						elemHtml	+= "<span class=\"add-on\" style=\"background:transparent;\"><div style=\"width:165px;text-align:center;\">"+labelName+"</div></span>";
												
						elemHtml +=
							"<input type=\"hidden\" id=\""+filterKey+"_op\" name=\""+filterKey+"_op\" value=\""+operator+"\" >" +
							"<select style=\"width: 230px;border: 1px solid #eeeeee;\" onblur=\"if(this.selectedIndex>=0){document.getElementById('"+ 
									filterKey +"_text').value=this.options[this.selectedIndex].innerHTML};\" onfocus=\"this.onfocus='';loadSelect('"+
									filterKey+"','/common/process/fillSelectProcessNewXML.jsp',token+'&elementType="+
									filterKey+"&elementToSelect='+this.options[this.selectedIndex].value,0,1);\" "+
									"id=\""+filterKey+"\" name=\""+filterKey+"\" class=\"m-wrap\">" + 
								"<option value=\""+paramValue+"\">"+paramText+"</option>"+
							"</select>" +
							"<input type=\"hidden\" id=\""+filterKey+"_text\" name=\""+filterKey+"_text\" value=\""+paramText+"\" />";
						
						elemHtml	+= "</div>";	

					}
					else if( type.equals("text"))
					{
						elemHtml	= "<div class=\"m-input-prepend\">";
						elemHtml	+= "<span class=\"add-on\" style=\"background:transparent;\"><div style=\"width:165px;text-align:center;\">"+labelName+"</div></span>";
												
						if( operator.equals(""))
						{
							elemHtml +=
								"<input type=\"hidden\" id=\""+filterKey+"_op\" name=\""+filterKey+"_op\" value=\"LIKE\" >" +
								"<input type=\"text\" id=\""+filterKey+"\" name=\""+filterKey+"\" value=\""+ paramValue +"\" class=\"m-wrap\" style=\"margin-bottom:0px;\"/> "+
								"<input type=\"hidden\" id=\""+filterKey+"_text\" name=\""+filterKey+"_text\" value=\""+paramValue+"\" />" ;
						}
						else
						{
							elemHtml += 
								"<input type=\"hidden\" id=\""+filterKey+"_op\" name=\""+filterKey+"_op\" value=\"LIKE\" >" +
								"<input type=\"text\" id=\""+filterKey+"\" name=\""+filterKey+"\" value=\""+ paramValue +"\"  class=\"m-wrap\" style=\"margin-bottom:0px;\"/> "+
								"<input type=\"hidden\" id=\""+filterKey+"_text\" name=\""+filterKey+"_text\" value=\""+paramValue+"\" />" ;
						}
						
						elemHtml	+= "</div>";
						
					}
					else if( type.equals("number"))
					{
						elemHtml	= "<div class=\"m-input-prepend\">";
						elemHtml	+= "<span class=\"add-on\" style=\"background:transparent;\"><div style=\"width:165px;text-align:center;\">"+labelName+"</div></span>";
												
						elemHtml +=
							"<input type=\"text\" onkeypress=\"return numbersonly(event);\" id=\""+filterKey+"\" name=\""+filterKey+"\" value=\""+ paramValue +"\" class=\"m-wrap\" /> "+
							"<input type=\"hidden\" id=\""+filterKey+"_text\" name=\""+filterKey+"_text\" value=\""+(paramValue.equals("-1")||paramValue.equals("")?"": paramValue)+"\" style=\"margin-bottom:0px;\" />" +
							"<input type=\"hidden\" id=\""+filterKey+"_op\" name=\""+filterKey+"_op\" value=\""+operator+"\" >";	
						
						elemHtml	+= "</div>";			
					}			
					else if( type.equals("datetime"))
					{
						elemHtml	= "<div class=\"m-input-prepend\">";
						elemHtml	+= "<span class=\"add-on\" style=\"background:transparent;\"><div style=\"width:165px;text-align:center;\">"+labelName+"</div></span>";
												
						elemHtml +=
							"<input type=\"hidden\" id=\""+filterKey+"_op\" name=\""+filterKey+"_op\" value=\""+operator+"\" >" +	
							"<input type=\"text\" id=\""+filterKey+"\" name=\""+filterKey+"\" class=\"m-wrap\" readonly=\"readonly\" style=\"margin-bottom:0px;\" >";						
						elemHtml	+= "</div>";	
						
						elemHtml	+=  "<script>"+
						
						"$( \"#"+filterKey+"\" ).datetimepicker({"+
						"	changeMonth: true,"+
						"	changeYear: true"+
						"});"+
						"</script>";
					}
					else if( type.equals("date"))
					{
						elemHtml	= "<div class=\"m-input-prepend\">";
						elemHtml	+= "<span class=\"add-on\" style=\"background:transparent;\"><div style=\"width:165px;text-align:center;\">"+labelName+"</div></span>";
												
						elemHtml +=
							"<input type=\"hidden\" id=\""+filterKey+"_op\" name=\""+filterKey+"_op\" value=\""+operator+"\" >" +	
							"<input type=\"text\" id=\""+filterKey+"\" name=\""+filterKey+"\" class=\"m-wrap\" readonly=\"readonly\" style=\"margin-bottom:0px;\" >";	
											
						elemHtml	+= "</div>";	
						
						elemHtml	+=  "<script>"+
						
						"$( \"#"+filterKey+"\" ).datepicker({"+
						"	changeMonth: true,"+
						"	changeYear: true"+						
						"});"+
						"</script>";

					}
		%>
					<tr>	
						<td style="text-align: left;margin-top:0px;padding:0px;background-color: whiteSmoke;">
							<%=elemHtml%>
						</td>				
					</tr>								
		<%			
				}
		%>									
				</table>
			</td>
		</tr>
		<tr>
			<td colspan="3" style="margin-top:0px;background-color: whiteSmoke;text-align: center;">
				<a href="javascript:toggleFilterDiv();" class="m-btn fuskey-stripe" style="margin: 0px;">Gizle <i class="m-icon-swapup"></i></a><a href="javascript:doFilter();" class="m-btn purple-stripe" style="margin: 0px;">Aramayı başlat <i class="m-icon-swapright"></i></a>
			</td>
		</tr>
	</table>
